<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台登录</title>
    <link rel="stylesheet" href="{{asset('/bootstrap/css/bootstrap.min.css')}}" />
    <script type="text/javascript" src="{{asset('/js/jquery.js')}}"></script>
    <script type="text/javascript" src="{{asset('/bootstrap/js/bootstrap.min.js')}}"></script>
    <style type="text/css">
        .login-form{
            position: relative;
            left: 300px;
            top:150px;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding: 30px;
            width: 500px;
        }
    </style>
</head>
<body>
</html>

<body >
    <div class="container">


        <div class='login-form'>
          <form class="form-horizontal" action="javascript:;">

              <div class="title">
                <h3>订单信息</h3>
              </div>
              @foreach ($detail as $v)
                <input type="hidden" value="{{$v->id}}" name="order_id">
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-2 control-label">姓名</label>
                  <div class="col-sm-10">
                    <input type="text" name="man" class="form-control" id="inputEmail3" value="{{$v->receiving_man}}">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-2 control-label">电话</label>
                  <div class="col-sm-10">
                    <input type="text" name="phone" class="form-control" id="inputEmail3" value="{{$v->receiving_phone}}">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-2 control-label">地址</label>
                  <div class="col-sm-10">
                    <input type="text" name="address"class="form-control" id="inputEmail3" value="{{$v->receiving_address}}">
                  </div>
                </div>
                @if($v->pay_state == 0)
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-2 control-label">总价</label>
                  <div class="col-sm-10">
                    <input type="text"name="money" class="form-control" id="inputEmail3" value="{{$v->total_money}}">
                  </div>
                </div>
                @endif

                <div class="form-group">
                  <div class="col-sm-offset-2 col-sm-10">
                    <button  class="btn btn-default btn-success" id="dochange">修改</button>
                  </div>
                </div>
              @endforeach
            </form>
        </div>
    </div>
</body>
</html>

<script type="text/javascript">
    $('#dochange').on('click', function () {
        var man = $('input[name="man"]').val();
        var phone = $('input[name="phone"]').val();
        var address = $('input[name="address"]').val();
        var money = $('input[name="money"]').val();
        var order_id = $('input[name="order_id"]').val();
        var token  = "{{csrf_token()}}";
        $.ajax({
            type:'post',
            url:"{{url('admin/DetailController/dochange')}}",
            data:{"man":man, "phone":phone,"address":address,"money":money, "_token":token,"order_id":order_id},
            dataType:'json',
            success:function (data) {
              if (data.code = 2000) {
                alert(data.msg);
                location.href= "{{url('admin/DetailController/index')}}";
              } else {
                alert(data.msg);
                location.href= "{{url('admin/DetailController/index')}}";
              }
            },

        });
    })
</script>
